﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace 作业9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private static string directory_path = "c:\\qs250";
        private static string directory_otherpath = "c:\\qqqq";
        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Directory.CreateDirectory(directory_path);
                button2.Enabled = true;
                button1.Enabled = false;
                button3.Enabled = true;
                button4.Enabled = true;
                button5.Enabled = true;
                MessageBox.Show("文件夹成功建立。", "警报");

            }
            catch (Exception mm)
            {
                MessageBox.Show("磁盘操作错误，警报" + Convert.ToString(mm), "警报");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                Directory.Delete(directory_path);
                button2.Enabled = false;
                button1.Enabled = true;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                MessageBox.Show("文件夹删除建立。", "警报");

            }
            catch (Exception mm)
            {
                MessageBox.Show("磁盘操作错误，警报" + Convert.ToString(mm), "警报");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                Directory.Move(directory_path,directory_otherpath);
                MessageBox.Show("文件夹移动成功。", "警报");

            }
            catch (Exception mm)
            {
                MessageBox.Show("磁盘操作错误，警报" + Convert.ToString(mm), "警报");
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {

            try
            {
         
                MessageBox.Show(string.Format("{0:G}",Directory.GetCreationTime(directory_path)), "提示");

            }
            catch (Exception mm)
            {
                MessageBox.Show("磁盘操作错误，原因" + Convert.ToString(mm), "警报");
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                string[] fileentries = Directory.GetFiles(directory_path);
                if (fileentries.Length != 0)
                {
                    foreach (string s in fileentries)
                    {
                        if (File.Exists(s))
                        {
                            MessageBox.Show("内有文件信息" + s, "提示");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("空文件夹", "提示");
                }
            }
            catch (Exception mm)
            {
                MessageBox.Show("磁盘操作错误，原因" + Convert.ToString(mm), "警报");
            }
        }
    }
}
